/**
* Created by Jimmy on 2017/7/12.
*/
<template>
  <div class="content">
    <!--<h4 class="title">测绘项目报价系统</h4>-->
    <div class="module">
      <moduleheader :title="one"></moduleheader>
      <div class="item-content">
        <div class="item-title">标题</div><input v-model="project_title" class="item-input" type="text" placeholder="请输入标题(必填)"/>
      </div>
      <div class="item-content">
        <div class="item-title">项目名称</div><input v-model="project_name" class="item-input" type="text" placeholder="请输入项目名称"/>
      </div>
      <div class="item-content">
        <div class="item-title">项目编号</div><input v-model="project_num" class="item-input" type="text" placeholder="请输入项目编号"/>
      </div>
      <div class="item-content">
        <div class="item-title">委托单位</div><input v-model="principal" class="item-input" type="text" placeholder="请输入委托单位"/>
      </div>
      <div class="item-content">
        <div class="item-title">负责人</div><input v-model="charge_man" class="item-input" type="text" placeholder="请输入负责人"/>
      </div>
      <div class="item-content">
        <div class="item-title">所在地</div><input v-model="project_addr" class="item-input" type="text" placeholder="请输入项目所在地"/>
      </div>
      <div class="item-content">
        <div class="item-title">复杂程度</div>
        <select v-model="hard_degree" class="item-select">
          <option value="0">简单</option>
          <option value="1">中等</option>
          <option value="2">复杂</option>
        </select>
        <div class="item-title">比例尺</div>
        <select v-model="scale" class="item-select">
          <option value="0">1 : 200</option>
          <option value="1">1 : 500</option>
          <option value="2">1 :1000</option>
          <option value="3">1 :2000</option>
          <option value="4">1 :5000</option>
          <option value="5">1 :10000</option>
        </select>
        <div class="item-title">报价依据</div>
        <select v-model="basis" class="item-select">
          <option value="0">《测绘生产成本费用定额》（2009年修订本）</option>
          <option value="1">《工程勘察设计收费标准》（2002年修订本）</option>
        </select>
      </div>
    </div>
    <div class="module">
      <moduleheader :title="two"></moduleheader>
      <div class="survey-item-title">
        <el-button type="primary" icon="el-icon-plus" size="mini" circle @click="addNewSurveyItem"></el-button>

        <!--<button type="button" class="btn btn-success btn-xs add" v-on:click="addNewSurveyItem">-->
          <!--<i class="el-icon-plus"></i>-->
        <!--</button>-->

        <span class="title-item">测绘专业</span>
        <span class="title-item">测绘项目</span>
        <span class="title-item">子项</span>
        <span class="title-item">等级</span>
        <span class="title-item">单位</span>
        <span class="title-item">单价</span>
        <span class="title-item">系(根)数</span>
        <span class="title-item">数量</span>
        <span class="title-item">金额</span>
        <span class="title-item">说明</span>
        <span class="title-item">依据出处</span>
      </div>
      <surveyitem v-for="(item, i) in survey_items"
                  :key="item.id"
                  :survey_item="item"
                  :hard_degree="hard_degree"
                  :index="i"
                  v-on:deleteSurveyItem="deleteSurveyItemByIndex"></surveyitem>
      <div class="item-content summation">
        <div class="item-title">测绘费合计</div>
        <div class="summation-value">{{ survey_total }} 元</div>
      </div>
      <div class="item-content summation" v-if="basis == 1">
        <div class="item-title">技术服务费</div>
        <div class="summation-value">{{ survey_tech }} 元 （测绘费 * 22%）</div>
      </div>
    </div>
    <div class="module">
      <moduleheader :title="three"></moduleheader>
      <div class="survey-item-title">
        <el-button type="primary" icon="el-icon-plus" size="mini" circle @click="addNewExtraItem"></el-button>

        <!--<button type="button" class="btn btn-success btn-xs add" v-on:click="addNewExtraItem">-->
          <!--<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>-->
        <!--</button>-->
        <span class="title-item">项目</span>
        <span class="title-item project-desc">项目描述</span>
        <span class="title-item">单位</span>
        <span class="title-item">单价</span>
        <span class="title-item">系(根)数</span>
        <span class="title-item">数量</span>
        <span class="title-item">金额</span>
        <span class="title-item">说明</span>
        <span class="title-item">依据出处</span>
      </div>
      <extraitem v-for="(item, i) in extra_items" :key="item.id" :extra_item="item" :index="i" v-on:deleteExtraItem="deleteExtraItemByIndex"></extraitem>
      <div class="item-content summation">
        <div class="item-title">附加费合计</div>
        <div class="summation-value">{{ extra_total }} 元</div>
      </div>
    </div>
    <div class="module">
      <moduleheader :title="four"></moduleheader>
      <div class="item-content summation">
        <div class="item-title">预算总价</div>
        <div class="summation-value">{{ budget_total }} 元</div>
      </div>
      <div class="item-content">
        <div class="item-title">优惠报价</div><input v-model.number="discount" class="item-input" type="text" placeholder="请输入优惠报价(若有)"/>
      </div>
      <div class="item-content">
        <div class="item-title">备注</div>
        <el-button type="primary" icon="el-icon-plus" size="mini" circle @click="addRemarkItem"></el-button>

        <!--<button type="button" class="btn btn-success btn-xs add last" v-on:click="addRemarkItem">-->
          <!--<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>-->
        <!--</button>-->
      </div>
      <remarkitem v-for="(item, i) in remarks" :key="item.id" :remark="item" :index="i" v-on:deleteRemarkItem="deleteRemarkItemByIndex"></remarkitem>
      <div class="item-content">
        <div class="item-title">报价单位</div><input v-model="company" class="item-input" type="text" placeholder="请输入报价单位"/>
      </div>
      <div class="item-content">
        <div class="item-title">报价日期</div><input v-model="report_date" class="item-input" type="text" placeholder="请输入报价日期"/>
      </div>
    </div>

    <div class="generate-report">
        <el-button type="primary" :loading="loading" @click="generate">生成报表</el-button>
    </div>
  </div>
</template>

<script>
  var surveyModelOne = {
    name: '测绘专业',
    major_selected: 0,
    project_selected: 0,
    sub_project_selected: 0,
    level_selected: 0,
    majors: [
      {
        name: '工程测量',
        projects: [
          {
            name: '控制测量',
            sub_projects: [
              {
                name: '水准测量',
                levels: [
                  {
                    name: '二、三、四等水准选埋',
                    unit: '点',
                    prices: [1457.86, 2245.43, 3113.16],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P24(一)3.'
                  },
                  {
                    name: '二等',
                    unit: '千米',
                    prices: [1351.45, 1908.59, 2828.15],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P24(一)3.'
                  },
                  {
                    name: '三等',
                    unit: '千米',
                    prices: [850.33, 1143.60, 1593.72],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P24(一)3.'
                  },
                  {
                    name: '四等',
                    unit: '千米',
                    prices: [693.70, 957.99, 1412.82],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P24(一)3.'
                  },
                  {
                    name: '等外',
                    unit: '千米',
                    prices: [331.00, 487.23, 627.80],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P24(一)3.'
                  }
                ]
              },
              {
                name: 'GPS测量',
                levels: [
                  {
                    name: 'C级',
                    unit: '点',
                    prices: [6283.76, 8450.69, 11484.71],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P24(一)4.'
                  },
                  {
                    name: 'D级',
                    unit: '点',
                    prices: [4549.97, 6830.15, 9459.13],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P24(一)4.'
                  },
                  {
                    name: 'E级',
                    unit: '点',
                    prices: [3904.37, 5753.84, 7968.96],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P24(一)4.'
                  }
                ]
              }
            ]
          },
          {
            name: '工程测图',
            sub_projects: [
              {
                name: '一般地区',
                levels: [
                  {
                    name: '1 : 2000',
                    unit: '幅',
                    prices: [11135.16, 16094.25, 24698.81],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P25(二)1.'
                  },
                  {
                    name: '1 : 1000',
                    unit: '幅',
                    prices: [8889.72, 13040.76, 19777.77],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P25(二)1.'
                  },
                  {
                    name: '1 : 500',
                    unit: '幅',
                    prices: [3544.96, 5443.61, 7915.79],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P25(二)1.'
                  }
                ]
              },
              {
                name: '建筑、工业地区',
                levels: [
                  {
                    name: '1 : 2000',
                    unit: '幅',
                    prices: [20828.1, 33054.99, 49260.26],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P25(二)2.'
                  },
                  {
                    name: '1 : 1000',
                    unit: '幅',
                    prices: [13067.4, 20373.73, 31720.5],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P25(二)2.'
                  },
                  {
                    name: '1 : 500',
                    unit: '幅',
                    prices: [7077.94, 9795.05, 13058.93],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P25(二)2.'
                  },
                  {
                    name: '1 : 200',
                    unit: '幅',
                    prices: [2168.62, 3258.22, 4196.19],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P25(二)2.'
                  }
                ]
              }
            ]
          },
          {
            name: '特殊精密工程测量',
            sub_projects: [
              {
                name: '--',
                levels: [
                  {
                    name: '--',
                    unit: '组天',
                    prices: [NaN, 2608.1, NaN],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P26(六).'
                  }
                ]
              }
            ]
          },
          {
            name: '市政工程测量',
            sub_projects: [
              {
                name: '工程线路测量',
                levels: [
                  {
                    name: '--',
                    unit: '千米',
                    prices: [5994.07, 6982.65, 10323.84],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P26(七)1.'
                  }
                ]
              },
              {
                name: '道路断面测量',
                levels: [
                  {
                    name: '纵断面',
                    unit: '千米',
                    prices: [2695.51, 3978.28, 5821.01],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P26(七)2.'
                  },
                  {
                    name: '横断面',
                    unit: '千米',
                    prices: [2402.83, 3685.6, 5528.33],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P26(七)2.'
                  }
                ]
              }
            ]
          },
          {
            name: '其他',
            sub_projects: [
              {
                name: '规划定桩测量',
                levels: [
                  {
                    name: '--',
                    unit: '件',
                    prices: [NaN, 3278.85, NaN],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P27(八)1.'
                  }
                ]
              },
              {
                name: '规划监督测量',
                levels: [
                  {
                    name: '验测平面位置',
                    unit: '边',
                    prices: [NaN, 3150.59, NaN],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P27(八)3.'
                  },
                  {
                    name: '验测高程、高度',
                    unit: '栋',
                    prices: [NaN, 2849.06, NaN],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P27(八)3.'
                  },
                  {
                    name: '规划面积测量',
                    unit: '千平方米',
                    prices: [1824.67, 2029.55, 2263.69],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P27(八)3.'
                  }
                ]
              },
              {
                name: '零星测量',
                levels: [
                  {
                    name: '--',
                    unit: '人工日',
                    prices: [NaN, 798.83, NaN],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P27(八)5.'
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        name: '海洋测绘与江湖水下测量',
        projects: [
          {
            name: '河道断面测量',
            sub_projects: [
              {
                name: '河宽 <100 米',
                levels: [
                  {
                    name: '1 : 1000',
                    unit: '千米',
                    prices: [3708.59, 5562.88, NaN],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P34(四)2.'
                  },
                  {
                    name: '1 : 500',
                    unit: '千米',
                    prices: [4635.73, 7417.17, NaN],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P34(四)2.'
                  },
                  {
                    name: '1 : 200',
                    unit: '千米',
                    prices: [6490.02, 10198.61, NaN],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P34(四)2.'
                  }
                ]
              },
              {
                name: '河宽 100~500 米',
                levels: [
                  {
                    name: '1 : 2000',
                    unit: '千米',
                    prices: [1854.30, 2781.44, NaN],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P34(四)2.'
                  },
                  {
                    name: '1 : 1000',
                    unit: '千米',
                    prices: [2317.87, 3245.02, NaN],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P34(四)2.'
                  },
                  {
                    name: '1 : 500',
                    unit: '千米',
                    prices: [3245.02, 4172.17, NaN],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P34(四)2.'
                  },
                  {
                    name: '1 : 200',
                    unit: '千米',
                    prices: [3708.59, 5562.88, NaN],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P34(四)2.'
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  }
  var surveyModelOneJson = JSON.stringify(surveyModelOne)
  var surveyModelTwo = {
    name: '测绘专业',
    major_selected: 0,
    project_selected: 0,
    sub_project_selected: 0,
    level_selected: 0,
    majors: [
      {
        name: '地面测量',
        projects: [
          {
            name: '控制测量',
            sub_projects: [
              {
                name: '三角（边）',
                levels: [
                  {
                    name: '二等',
                    unit: '点',
                    prices: [4263, 4842, 6232],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '三等',
                    unit: '点',
                    prices: [3136, 3565, 4584],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '四等',
                    unit: '点',
                    prices: [2737, 3112, 4006],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '一级',
                    unit: '点',
                    prices: [1096, 1244, 1602],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '二级',
                    unit: '点',
                    prices: [728, 829, 1069],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  }
                ]
              },
              {
                name: '导线',
                levels: [
                  {
                    name: '三等',
                    unit: '千米',
                    prices: [2818, 3203, 4122],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '四等',
                    unit: '千米',
                    prices: [2186, 2484, 3196],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '一级',
                    unit: '千米',
                    prices: [1552, 1764, 2269],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '二级',
                    unit: '千米',
                    prices: [1086, 1234, 1589],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '图根点',
                    unit: '点',
                    prices: [89, 101, 131],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  }
                ]
              },
              {
                name: '水准',
                levels: [
                  {
                    name: '二等',
                    unit: '千米',
                    prices: [877, 997, 1283],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '三等',
                    unit: '千米',
                    prices: [438, 500, 643],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '四等',
                    unit: '千米',
                    prices: [220, 250, 323],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '五等',
                    unit: '千米',
                    prices: [167, 188, 242],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '图根',
                    unit: '千米',
                    prices: [111, 124, 162],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  }
                ]
              },
              {
                name: 'GPS测量',
                levels: [
                  {
                    name: 'C级',
                    unit: '点',
                    prices: [3727, 4274, 5500],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: 'D级',
                    unit: '点',
                    prices: [3198, 3632, 4671],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: 'E级',
                    unit: '点',
                    prices: [2821, 3203, 4123],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  }
                ]
              }
            ]
          },
          {
            name: '地形测量',
            sub_projects: [
              {
                name: '一般地区',
                levels: [
                  {
                    name: '1 : 200',
                    unit: '平方千米',
                    prices: [76780, 102374, 163795],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '1 : 500',
                    unit: '平方千米',
                    prices: [33383, 44510, 71216],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '1 : 1000',
                    unit: '平方千米',
                    prices: [15174, 20232, 32374],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '1 : 2000',
                    unit: '平方千米',
                    prices: [6676, 8901, 14244],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '1 : 5000',
                    unit: '平方千米',
                    prices: [1975, 2630, 4210],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '1 : 10000',
                    unit: '平方千米',
                    prices: [1109, 1478, 2364],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  }
                ]
              },
              {
                name: '建筑群区',
                levels: [
                  {
                    name: '1 : 200',
                    unit: '平方千米',
                    prices: [76780, 102374, 163795],
                    coefficient: 1.8,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '1 : 500',
                    unit: '平方千米',
                    prices: [33383, 44510, 71216],
                    coefficient: 2.0,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '1 : 1000',
                    unit: '平方千米',
                    prices: [15174, 20232, 32374],
                    coefficient: 2.0,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '1 : 2000',
                    unit: '平方千米',
                    prices: [6676, 8901, 14244],
                    coefficient: 2.0,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '1 : 5000',
                    unit: '平方千米',
                    prices: [1975, 2630, 4210],
                    coefficient: 2.0,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '1 : 10000',
                    unit: '平方千米',
                    prices: [1109, 1478, 2364],
                    coefficient: 2.0,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  }
                ]
              }
            ]
          },
          {
            name: '断面测量',
            sub_projects: [
              {
                name: '水平比例尺',
                levels: [
                  {
                    name: '1 : 200',
                    unit: '千米',
                    prices: [1016, 1354, 1864],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '1 : 500',
                    unit: '千米',
                    prices: [785, 1047, 1440],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '1 : 1000',
                    unit: '千米',
                    prices: [607, 809, 1113],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '1 : 2000',
                    unit: '千米',
                    prices: [468, 625, 860],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  },
                  {
                    name: '1 : 5000',
                    unit: '千米',
                    prices: [362, 481, 665],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P5表2.2-2'
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        name: '水域测量',
        projects: [
          {
            name: '湖、江、河、塘、沼泽地、积水区',
            sub_projects: [
              {
                name: '比例尺',
                levels: [
                  {
                    name: '1 : 200',
                    unit: '平方千米',
                    prices: [204748, 272301, 382875],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P7表2.3-2'
                  },
                  {
                    name: '1 : 500',
                    unit: '平方千米',
                    prices: [89020, 118396, 166468],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P7表2.3-2'
                  },
                  {
                    name: '1 : 1000',
                    unit: '平方千米',
                    prices: [40464, 53817, 75680],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P7表2.3-2'
                  },
                  {
                    name: '1 : 2000',
                    unit: '平方千米',
                    prices: [17803, 23680, 33294],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P7表2.3-2'
                  },
                  {
                    name: '1 : 5000',
                    unit: '平方千米',
                    prices: [5260, 7002, 9838],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P7表2.3-2'
                  },
                  {
                    name: '1 : 10000',
                    unit: '平方千米',
                    prices: [2955, 3924, 5530],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P7表2.3-2'
                  }
                ]
              }
            ]
          },
          {
            name: '河道断面',
            sub_projects: [
              {
                name: '比例尺',
                levels: [
                  {
                    name: '1 : 200',
                    unit: '千米',
                    prices: [3245, 4316, 6474],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P7表2.3-2'
                  },
                  {
                    name: '1 : 500',
                    unit: '千米',
                    prices: [2636, 3506, 5261],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P7表2.3-2'
                  },
                  {
                    name: '1 : 1000',
                    unit: '千米',
                    prices: [2023, 2698, 4046],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P7表2.3-2'
                  },
                  {
                    name: '1 : 2000',
                    unit: '千米',
                    prices: [1559, 2075, 3112],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P7表2.3-2'
                  },
                  {
                    name: '1 : 5000',
                    unit: '千米',
                    prices: [1268, 1686, 2529],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P7表2.3-2'
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        name: '其他测量',
        projects: [
          {
            name: '小型工程测量',
            sub_projects: [
              {
                name: '小面积测量、配合其他工程测量',
                levels: [
                  {
                    name: '--',
                    unit: '组日',
                    prices: [1000, 1000, 1000],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P8表2.6-1'
                  }
                ]
              }
            ]
          },
          {
            name: '定点测量',
            sub_projects: [
              {
                name: '各种勘探点',
                levels: [
                  {
                    name: '--',
                    unit: '组日',
                    prices: [1000, 1000, 1000],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P8表2.6-1'
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        name: '工程物探',
        projects: [
          {
            name: '地下管线探测',
            sub_projects: [
              {
                name: '电缆（电力、通讯等）',
                levels: [
                  {
                    name: '--',
                    unit: '千米',
                    prices: [1800, 3600, 6300],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P31续表7.2-1'
                  }
                ]
              },
              {
                name: '金属管道',
                levels: [
                  {
                    name: '--',
                    unit: '千米',
                    prices: [2250, 4500, 7200],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P31续表7.2-1'
                  }
                ]
              },
              {
                name: '非金属管道',
                levels: [
                  {
                    name: '--',
                    unit: '千米',
                    prices: [2700, 5400, 9000],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P31续表7.2-1'
                  }
                ]
              },
              {
                name: '下水道（有窖井）',
                levels: [
                  {
                    name: '--',
                    unit: '千米',
                    prices: [1350, 2700, 5400],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P31续表7.2-1'
                  }
                ]
              },
              {
                name: '盲探管线',
                levels: [
                  {
                    name: '--',
                    unit: '平方米',
                    prices: [1.0, 1.5, 3.0],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P31续表7.2-1'
                  }
                ]
              }
            ]
          },
          {
            name: '地下管线泄漏探测',
            sub_projects: [
              {
                name: '漏水点探测',
                levels: [
                  {
                    name: '--',
                    unit: '千米',
                    prices: [3600, 3600, 3600],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P31续表7.2-1'
                  }
                ]
              },
              {
                name: '输油、输气管漏点',
                levels: [
                  {
                    name: '--',
                    unit: '千米',
                    prices: [4500, 4500, 4500],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P31续表7.2-1'
                  }
                ]
              },
              {
                name: '供电、通讯电缆泄漏点',
                levels: [
                  {
                    name: '--',
                    unit: '千米',
                    prices: [3600, 3600, 3600],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P31续表7.2-1'
                  }
                ]
              },
              {
                name: '防腐层完整性',
                levels: [
                  {
                    name: '--',
                    unit: '千米',
                    prices: [3600, 3600, 3600],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P31续表7.2-1'
                  }
                ]
              }
            ]
          },
          {
            name: '地下障碍物探测',
            sub_projects: [
              {
                name: '地质雷达',
                levels: [
                  {
                    name: '--',
                    unit: '千米',
                    prices: [13500, 13500, 13500],
                    coefficient: 1,
                    quantity: 0,
                    total: 0,
                    description: '',
                    reference: 'P31续表7.2-1'
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  }
  var surveyModelTwoJson = JSON.stringify(surveyModelTwo)
  var extraModel = {
    name: '附加费用',
    project_selected: 0,
    projects: [
      {
        name: '材料费',
        project_desc: '控制留点材料及埋设费用',
        unit: '点',
        prices: 50,
        coefficient: 1,
        quantity: 0,
        total: 0,
        description: '市场价',
        reference: ''
      },
      {
        name: '晒图费',
        project_desc: '标准数字化地形图',
        unit: '张',
        prices: 50,
        coefficient: 1,
        quantity: 0,
        total: 0,
        description: '市场价',
        reference: ''
      },
      {
        name: '进出场费',
        project_desc: '车费、设备搬运费',
        unit: '次',
        prices: 1000,
        coefficient: 1,
        quantity: 0,
        total: 0,
        description: '市场价',
        reference: ''
      },
      {
        name: '资料费',
        project_desc: '成果报告及光盘',
        unit: '套',
        prices: NaN,
        coefficient: 1,
        quantity: 0,
        total: 0,
        description: '市场价',
        reference: ''
      }
    ]
  }
  var extraModelJson = JSON.stringify(extraModel)
  var remarkModel = {
    name: '本项目报价按照中华人民共和国财政部、国家测绘局颁布的《测绘生产成本费用定额》(2009版)执行；'
  }

  import moduleheader from '../components/budget/moduleHeader.vue'
  import surveyitem from '../components/budget/surveyItem.vue'
  import extraitem from '../components/budget/extraItem.vue'
  import remarkitem from '../components/budget/remarkItem.vue'
//  import $ from 'jquery'

  export default {
    components: {
      moduleheader,
      surveyitem,
      extraitem,
      remarkitem
    },
    data () {
      return {
        loading:false,
        one: '基本信息',
        two: '测绘费用',
        three: '附加费用',
        four: '汇总',
        principal: '',
        charge_man: '',
        project_title: '',
        project_name: '',
        project_num: '',
        project_addr: '',
        hard_degree: '1',
        scale: '1',
        basis: '0',
        survey_items: [],
        extra_items: [],
        company: '上海市岩土地质研究院有限公司',
        remarks: [remarkModel],
        discount: ''
      }
    },
    computed: {
      survey_total: function () {
        var len = this.survey_items.length
        var total = 0
        for (var i = 0; i < len; i++) {
          var item = this.survey_items[i]
          var atotal = item.majors[item.major_selected].projects[item.project_selected].sub_projects[item.sub_project_selected].levels[item.level_selected].total
          total += parseFloat(atotal)
        }
        return (total * 1).toFixed(2)
      },
      survey_tech: function () {
        if (this.base === '0') {
          return 0
        } else {
          return (this.survey_total * 0.22).toFixed(2)
        }
      },
      extra_total: function () {
        var len = this.extra_items.length
        var total = 0
        for (var i = 0; i < len; i++) {
          var item = this.extra_items[i]
          var atotal = item.projects[item.project_selected].total
          total += parseFloat(atotal)
        }
        return (total * 1).toFixed(2)
      },
      budget_total: function () {
        if (this.basis === '0') {
          return (parseFloat(this.survey_total) + parseFloat(this.extra_total)).toFixed(2)
        } else {
          return (parseFloat(this.survey_total) + parseFloat(this.extra_total) + parseFloat(this.survey_tech)).toFixed(2)
        }
      },
      report_date: function () {
        var myDate = new Date()
        return myDate.getFullYear() + '年' + (parseInt(myDate.getMonth()) + 1) + '月' + myDate.getDate() + '日'
      },
      hard_desc: function () {
        var output = ''
        switch (this.hard_degree) {
          case '0':
            output = '简单'
            break
          case '1':
            output = '中等'
            break
          case '2':
            output = '困难'
        }
        return output
      }
    },
    watch: {
      basis: function () {
        this.survey_items = []
        var model = {
          name: ''
        }
        if (this.basis === '0') {
          model.name = '本项目报价按照中华人民共和国财政部、国家测绘局颁布的《测绘生产成本费用定额》(2009版)执行；'
          this.remarks[0] = model
        } else {
          model.name = '本项目报价按照国家发展计划委员会、建设部颁发的《工程勘察设计收费标准》（2002年修订本）执行；'
          this.remarks[0] = model
        }
      }
    },
    methods: {
      generate: function () {
        this.loading = true
        if (this.project_title !== '') {
          var output = JSON.parse(JSON.stringify(this.$data))
          delete output.one
          delete output.two
          delete output.three
          delete output.four
          switch (output.scale) {
            case '0':
              output.scale = '1 : 200'
              break
            case '1':
              output.scale = '1 : 500'
              break
            case '2':
              output.scale = '1 : 1000'
              break
            case '3':
              output.scale = '1 : 2000'
              break
            case '4':
              output.scale = '1 : 5000'
              break
            case '5':
              output.scale = '1 : 10000'
              break
          }
          if (this.discount !== '') {
            output.discount = (this.discount * 1).toFixed(2)
          }
          output.hard_desc = this.hard_desc
          output.survey_total = this.survey_total
          output.survey_tech = this.survey_tech
          output.budget_total = this.budget_total
          output.report_date = this.report_date
          output.extra_total = this.extra_total
          output = JSON.stringify(output)

          console.log(output)
          this.$http.post(this.domain + '/budget/reporter',
            {arg:output}
          ).then((response) => {
            let downloadElement = document.createElement('a');
            let href = this.domain +response.data.URL; //创建下载的链接
            downloadElement.href = href;
            downloadElement.download = response.data.Title; //下载后文件名
            document.body.appendChild(downloadElement);
            downloadElement.click(); //点击下载
            document.body.removeChild(downloadElement); //下载完成移除元素
            window.URL.revokeObjectURL(href);
            this.loading = false

          }).catch(function (response) {
            this.$message.error(response.data)
            this.loading = false
          })
        } else {
          alert('请输入标题')
          this.loading = false
        }
      },
      addNewSurveyItem: function () {
        if (this.basis === '0') {
          this.survey_items.push(JSON.parse(surveyModelOneJson))
        } else {
          this.survey_items.push(JSON.parse(surveyModelTwoJson))
        }
      },
      deleteSurveyItemByIndex: function (index) {
        this.survey_items.splice(index, 1)
      },
      addNewExtraItem: function () {
        this.extra_items.push(JSON.parse(extraModelJson))
      },
      deleteExtraItemByIndex: function (index) {
        this.extra_items.splice(index, 1)
      },
      addRemarkItem: function () {
        var model = {
          name: ''
        }
        if (this.remarks.length === 0) {
          if (this.basis === '0') {
            model.name = '本项目报价按照中华人民共和国财政部、国家测绘局颁布的《测绘生产成本费用定额》(2009版)执行；'
            this.remarks.push(model)
          } else {
            model.name = '本项目报价按照国家发展计划委员会、建设部颁发的《工程勘察设计收费标准》（2002年修订本）执行；'
            this.remarks.push(model)
          }
        } else {
          this.remarks.push(model)
        }
      },
      deleteRemarkItemByIndex: function (index) {
        this.remarks.splice(index, 1)
      }
    }
  }
</script>

<style scoped>
  .el-button--primary{
    height: 28px;
    margin-top: 6px;
  }
  /*.el-button.is-circle{*/
    /*!*width: 28px;*!*/
    /*height: 28px;*/
    /*!*margin-top: 6px;*!*/
  /*}*/
  .generate-report .el-button--primary{
    height: 40px;
    margin: 0 0;
  }
  .title{
    font-size: 20px;
    height: 50px;
    line-height: 50px;
    text-align: center;
  }
  .module{
    margin: 10px;
    background: white;
    border: 1px solid #ededed;
    padding: 12px 12px 12px 12px;
  }
  .item-content{
    height: 30px;
    background: white;
    display: flex;
    flex-flow: row;
    margin: 10px 0;
    /*background: red;*/
  }
  .item-title{
    flex: 0 0 70px;
    line-height: 30px;
    text-align: left;
    font-weight: 500;
    /*background: red;*/
  }
  .item-input{
    flex-grow: 1;
    padding: 0 12px;
    outline: none;
    border: 1px solid #ededed;
  }
  .item-input:focus{
    border: 1px solid #e74c3c;
  }
  .item-select{
    flex: 0 0 80px;
    outline: none;
    margin-right: 30px;
  }
  .item-select:last-of-type{
    flex-grow: 1;
    margin-right: 0;
  }
  .survey-item-title{
    height: 40px;
    display: flex;
    /*background: red;*/
    margin: 10px 0 5px 0;
    border-bottom: 1px solid #ededed;
  }
  .title-item{
    line-height:40px;
    text-align: center;
    flex-basis: 0;
    flex-grow: 1;
    flex-shrink: 0;
    margin: 0 5px;
    /*border: 1px solid black;*/
  }
  .title-item:last-of-type{
    margin-right: 0;
  }
  .add{
    /*flex: 0 0 20px;*/
    color: white;
    height: 20px;
    margin: 10px 10px 5px 0;
  }
  .last{
    margin: 5px 10px 5px 0;
  }
  .summation{
    border-top: 1px solid #ededed;
  }
  .summation-value{
    flex-grow: 1;
    text-align: left;
    line-height: 30px;
    font-weight: 500;
    padding-left: 20px;
  }
  .project-desc{
    flex-grow: 3;
    flex-basis: 0;
    padding: 0 10px;
  }
  .generate-report{
    margin:0 auto;
    /*background: red;*/
    width: 98px;
  }
  .content{
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 20px;
    overflow: auto;
    /*padding-bottom: 60px;*/
  }
</style>
